﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>createRule</title>
    <script src="../../Scripts/jquery-1.8.0.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            //这里 我们需要 课时  和  作业的次数啊


            $("#selectCourse").change(function () {
                var val = $("#selectCourse").val();
                var vals = new Array();
                vals = val.split(',');

                var lessonTimes = vals[1];
                var workTimes = vals[2];
                $('#home').html(workTimes);
                $('.times').html(lessonTimes);

            })

            $("#SituationType").change(function () {
                var val = $(this).val();
                var vals = new Array();
                vals = val.split(',');
                $('#percent').val(vals[1]);

                var obj = $(".zoom");
                if (vals[2] == "作业成绩") {

                    obj.each(function (i) {
                        $("#homeId").val(vals[0]);
                        if (i == 0) {
                            $(this).slideDown();
                        } else {
                            $(this).hide();
                        }


                    })

                } else if (vals[2] == "纪律成绩") {
                    $("#chuPid").val(vals[0]);
                    obj.each(function (i) {
                        if (i == 1) {
                            $(this).slideDown();
                        } else {
                            $(this).hide();
                        }

                    })


                } else if (vals[2] == "课堂表现") {
                    $("#Pid").val(vals[0]);
                    obj.each(function (i) {
                        if (i == 2) {
                            $(this).slideDown();
                        } else {
                            $(this).hide();
                        }

                    })

                }





            })
        })

        function saveClassPerform() {

            var objs = $("#classInfo");
            var pid = objs.find("#Pid").val();

            var min = objs.find("#min").val();
            var max = objs.find("#max").val();

            var obj = $("#ketang");
            var input = obj.find(':input');

            var typesfen = "";
            input.each(function () {
                typesfen += $(this).val() + ",";
            })

            var typeName = $(".typeName");
            var types = "";
            typeName.each(function () {
                types += $(this).html();
            })

            $.post("/Rule/saveDiscipline", { pId: pid, min: min, max: max, typesfen: typesfen, types: types }, function () {


                alert("保存成功!")
                $("#classInfo").find(":input[type='text']:gt(0)").val(" ");


            })

        }

        function saveQing() {

            //第一步货值的啊
            var objs = $("#chuqing");
            var pid = objs.find("#chuPid").val();

            var min = objs.find("#min").val();
            var max = objs.find("#max").val();

            var obj = $("#chu");
            var input = obj.find(':input');

            var typesfen = "";
            input.each(function () {
                typesfen += $(this).val() + ",";
            })

            var typeName = $(".qingName");
            var types = "";
            typeName.each(function () {
                types += $(this).html();
            })


            $.post("/Rule/saveDiscipline", { pId: 262172, min: min, max: max, typesfen: typesfen, types: types }, function () {


                alert("保存成功!")
                $("#chuqing").find(":input[type='text']:gt(0)").val(" ");


            })




        }

        function saveHome() {
            var objs = $("#homeWork");
            var pid = objs.find("#homeId").val();
            var times = $("#times").val();

            var obj = $(".one");
            var str = "";
            obj.each(function (i) {

                str += $(this).val() + ',';
                if ((parseInt(i + 1)) % 3 == 0) {
                    str = str + '!';
                }

            })

            $.post("/Rule/CreateFunction", { pid: 262172, up: 20, down: 30, str: "3|1,3!1-4,8!2|4,8!2" }, function () {

                alert("保存成功!")

            })
        }

        function addhang() {


            $("#fucktable tr:last").after('<tr><td><input class="one" type="text" /></td><td><input class="one"  type="text" /></td> <td><input class="one"  type="text" /></td> <td></td></tr>')


        }
    
    </script>
</head>
<body style="font-size: 13px;">
    <div id="outer" style="height: 660px; width: 1100px; border: 1px solid gray;">
        <div id="up" style="height: 80px; width: 400px; border: 1px solid gray; float: left;
            margin-top: 20px;">
            请选择类型： @Html.Raw(@TempData["types"].ToString()) &nbsp;&nbsp; 权重:<input id="percent"
                type="text" style="width: 38px; color: Red;" />
        </div>
        <input type="button" value="保存规则" onclick="saveHome()" />
        <div id="homeWork" class="zoom" style="height: 200px; width: 700px; border: 1px solid  gray;
            display: none; margin-top: 110px;">
            父级id<input id="homeId" type="text" />
            当布置作业<input type="text" id="times" style="width: 24px; color: Red;" />次
            <table width="200" border="1" id="fucktable">
                <tr>
                    <td>
                        上限
                    </td>
                    <td>
                        下限
                    </td>
                    <td>
                        (扣)每次/分
                    </td>
                    <td>
                        <input type="button" value="添加" onclick="addhang()" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <input class="one" type="text" />
                    </td>
                    <td>
                        <input class="one" type="text" />
                    </td>
                    <td>
                        <input class="one" type="text" />
                    </td>
                    <td>
                        <input type="text" style="border: 0px;" />
                    </td>
                </tr>
            </table>
        </div>
        <div id="chuqing" class="zoom" style="height: 300px; width: 700px; border: 1px solid  gray;
            display: none; margin-top: 110px;">
            父节点<input id="chuPid" type="text" style="width: 40px;" /><br />
            当课时： 大于<input id="min" type="text" style="width: 30px;" />
            小于
            <input id="max" type="text" style="width: 30px;" />
            @{
         
                var list2 = @TempData["jilv"] as IList<string>;
                <table id="chu" width="300" border="1">
                    <tr>
                        <td>
                            违纪现象：
                        </td>
                        <td>
                            (扣)每次/分
                        </td>
                    </tr>
                    @foreach (string name in list2)
                    {
                        <tr>
                            <td class="qingName">@name
                            </td>
                            <td>
                                <input type="text" />
                            </td>
                        </tr>
             
                    }
                </table>
         
            }
            <input type="button" value="保存规则" onclick="saveQing()" />
        </div>
        <div id="classInfo" class="zoom" style="height: 300px; width: 700px; border: 1px solid  gray;
            display: none; margin-top: 110px;">
            父节点<input id="Pid" type="text" style="width: 40px;" />
            当课时： 大于<input id="min" type="text" style="width: 30px;" />
            小于
            <input id="max" type="text" style="width: 30px;" />
            <br />
            @{
                var list = @TempData["input"] as IList<ZDSoft.UPMS.Model.BusinessPart.SituationType>;
        
                <table id="ketang" width="333" height="82" border="1" style="margin-left: 30px;">
                    <tr>
                        <td height="33">
                            表现类型
                        </td>
                        <td>
                            （扣/加）每次/分
                        </td>
                    </tr>
                    @foreach (ZDSoft.UPMS.Model.BusinessPart.SituationType type in list)
                    {
            
                        <tr>
                            <td height="41" class="typeName">@type.Name:
                            </td>
                            <td>
                                <input type="text" />
                            </td>
                        </tr>
             
             
             
                    }
                </table>
       
            }
            <input type="button" onclick="saveClassPerform()" value="提交规则" />
        </div>
    </div>
</body>
</html>
